import { StatusBar } from "expo-status-bar";
import { Platform, StyleSheet, View, Text, Button } from "react-native";
import "../global.css";
import { useRouter } from "expo-router";
import { useDispatch } from "react-redux";

export default function ModalScreen() {
  const router = useRouter();
  const dispatch = useDispatch();

  function jump() {
    console.log(1);
    dispatch({ type: "test/setName", payload: "阿尔卑斯" });
    dispatch({ type: "test/setAge", payload: "100" });
    router.push("/sub/subpage");
  }
  return (
    <View style={styles.container}>
      <Text className="text-3xl">Modal</Text>
      <Button title="跳转并通过redux修改子页面的数字" onPress={jump}></Button>

      <StatusBar style={Platform.OS === "ios" ? "light" : "auto"} />
    </View>
  );
}

// 添加页面的静态配置
ModalScreen.config = {
  options: {
    title: "自定义标题1", // 定义页面标题
  },
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: "center",
    justifyContent: "center",
  },
  title: {
    fontSize: 20,
    fontWeight: "bold",
    color: "red",
  },
  separator: {
    marginVertical: 30,
    height: 1,
    width: "80%",
  },
});
